home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / standards / sgml / nist / incs / didefs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-13  |  8.6 KB  |  226 lines

  1. /* National Institute of Standards and Technology (NIST)
  2. /* National Computer System Laboratory (NCSL)
  3. /* Office Systems Engineering (OSE) Group
  4. /* ********************************************************************
  5. /*                            D I S C L A I M E R
  6. /*                              (March 8, 1989)
  7. /*  
  8. /* There is no warranty for the NIST NCSL OSE SGML parser and/or the NIST
  9. /* NCSL OSE SGML parser validation suite.  If the SGML parser and/or
  10. /* validation suite is modified by someone else and passed on, NIST wants
  11. /* the parser's recipients to know that what they have is not what NIST
  12. /* distributed, so that any problems introduced by others will not
  13. /* reflect on our reputation.
  14. /* 
  15. /* Policies
  16. /* 
  17. /* 1. Anyone may copy and distribute verbatim copies of the SGML source
  18. /* code as received in any medium.
  19. /* 
  20. /* 2. Anyone may modify your copy or copies of SGML parser source code or
  21. /* any portion of it, and copy and distribute such modifications provided
  22. /* that all modifications are clearly associated with the entity that
  23. /* performs the modifications.
  24. /* 
  25. /* NO WARRANTY
  26. /* ===========
  27. /* 
  28. /* NIST PROVIDES ABSOLUTELY NO WARRANTY.  THE SGML PARSER AND VALIDATION
  29. /* SUITE ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
  30. /* EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  31. /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  32. /* THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS
  33. /* WITH YOU.  SHOULD THE SGML PARSER OR VALIDATION SUITE PROVE DEFECTIVE,
  34. /* YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  35. /* 
  36. /* IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL NIST BE LIABLE FOR
  37. /* DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL,
  38. /* INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  39. /* INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
  40. /* BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
  41. /* FAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
  42. /* NIST) THE PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF
  43. /* SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  44. */
  45.  
  46. /************************************************************************/
  47. /*   TITLE:          SGML Parser                                        */
  48. /*   SYSTEM:         Document Processor                                 */
  49. /*   SUBSYSTEM:                                                         */
  50. /*   SOURCE FILE:    DEFS.H                                             */
  51. /*   AUTHOR:         Steve Lindeman, Fred Maples                        */
  52. /*                                                                      */
  53. /*   DATE CREATED:                                                      */
  54. /*   LAST MODIFIED:                                                     */
  55. /*                                                                      */
  56. /*                  REVISIONS                                           */
  57. /*   WHEN      WHO            WHY                                       */
  58. /************************************************************************/
  59.  
  60. #include "qntyset.h" /* copied straight out of standard */
  61. #include "dtd.h"     /* Jim's definitions for document type definition */
  62. #include "semantic.h"
  63.  
  64. typedef enum read_state { GETOLD, GETNEW } READ_STATE;
  65.  
  66. typedef enum status { FOUND, NFDHT, NFSH } STATUS;
  67.  
  68. typedef enum tknretval { TEXT, MARKUP_FOUND } TKNRETVAL;
  69.  
  70. typedef enum occurind { PLUS, ONE, OPT, OI_IS_NULL } OCCURIND;
  71.  
  72. #define BOOLEAN int
  73.  
  74. typedef struct groupdesc { /* structure for entry into linked  */
  75.    char groupname[NAMELEN+1];   /* list containing name token group */
  76.    struct groupdesc *next; /* items           */
  77.    } GROUPDESC,*GROUPPTR;
  78.  
  79. typedef struct attrdesc {  /* structure for entry into attribute */
  80.    struct attrdesc *next;  /* linked list used in start tags     */
  81.    BOOLEAN processed;
  82.    char attrname[NAMELEN+1];
  83.    DECLVAL dvcode;
  84.    ADFLT defcode;
  85.    union {
  86.      char *currdef;
  87.      GROUPDESC *currgrp;
  88.      } u2;
  89.    GROUPDESC *groupp;
  90.    } ATTRDESC,*ATTRPTR;
  91.  
  92. typedef struct tnode {     /* structure for entry into binary    */
  93.    int nodeid;       /* tree describing content model for  */
  94.    char occurind;    /* generic identifiers           */
  95.    char copyoi;
  96.    enum CONTEXT contreq;
  97.    enum CONTEXT copycontreq;
  98.    BOOLEAN changed;
  99.    BOOLEAN contref_attr;
  100.    struct tnode *left;
  101.    union {
  102.      struct tnode *right;
  103.      struct tnode *llptr;
  104.      } u;
  105.    struct tnode *next;
  106.    } TNODE,*TPTR;
  107.  
  108. typedef struct exceptdesc {
  109.    int tokenid;
  110.    BOOLEAN changed;
  111.    struct exceptdesc *nextlocal;
  112.    struct exceptdesc *nextglobal;
  113.    } EXCEPTDESC,*EXCEPTPTR;
  114.  
  115. typedef struct stentry {   /* structure for entry in symbol        */
  116.    char nametoken[NAMELEN+1];   /* table containing generic identifier, */
  117.    int tokenid;         /* its token value and associated ptrs  */
  118.    TNODE *cmptr;     /* to more information        */
  119.    int miniexcept;
  120.    ATTRDESC *adptr;
  121.    int num_open;
  122.    int content_type;
  123.    EXCEPTDESC *inclusion;
  124.    EXCEPTDESC *exclusion;
  125.    } STENTRY,*STPTR;
  126.  
  127. typedef struct entitydesc {         /* structure for entry in internal */
  128.    char entityname[NAMELEN+1];      /* general entity linked list      */
  129.    char *entityvalue;
  130.    int entitytype;
  131.    struct entitydesc *next;
  132.    } ENTITYDESC,*ENTITYPTR;
  133.  
  134. typedef struct id_idref_desc {      /* structure for entry in ID or  */
  135.    char name[NAMELEN+1];         /* IDREF linked list        */
  136.    struct id_idref_desc *next;
  137.    } ID_IDREF_DESC,*ID_IDREF_PTR;
  138.  
  139. typedef struct input_stack { 
  140.    int inchar;
  141.    struct input_stack *next;
  142.    } INPUT_STACK,*INPUT_STACK_PTR;
  143.  
  144. typedef struct out_queue {
  145.    int code;
  146.    char str1[ATTSPLEN];
  147.    char str2[ATTSPLEN];
  148.    struct out_queue *next;
  149.    } OUT_QUEUE,*OUT_QUEUE_PTR;
  150.  
  151. #define PATHLEN (64)  /* valid length for path description */
  152. #define INTSIZE 15 /* machine dependent -- high order bit for integer */
  153. #define HIGHBIT (1 << INTSIZE)  /* used to turn on high bit of an integer */
  154.  
  155. #define ERRMSGLEN 80
  156. #define MAXCOL 110
  157. /*  this probably would be different under UNIX */
  158. #define DIR_SEPERATOR '\\'
  159.  
  160. #define PCDATA (-1)   /* the ones found in the content model definition */
  161. #define RCDATA (-3)  /* replaceable character data */
  162. #define CDATA (-4)   /* character data */
  163. #define EMPTY (-5)   /* EMPTY content model */
  164. #define ANY (-6)
  165.  
  166. #define MAX_ERRORS (1)
  167.  
  168. #define STAGO (100)   /* start tag open */
  169. #define ETAGO (STAGO+1)   /* end tag open */
  170. #define TAGC (ETAGO+1)    /* tag close */
  171. #define NODELIM (TAGC+1) /* returned from getdelim, none found */
  172. #define PIO (NODELIM+1)     /* processing instruction open */
  173. #define MDO (PIO+1)  /* markup declaration open */
  174.  
  175. /*  these would change with a different character set other than ASCII */
  176. #define VI '='
  177. #define MARKUP_END '>'
  178. #define MARKUP_START '<'
  179. #define SEPCHAR 0x9
  180. #define CHARSET_LOWBOUND 0     /* ASCII lower limit */
  181. #define CHARSET_HIGHBOUND 127  /* ASCII upper limit */
  182.  
  183. /*  CRs are not significant after declarations */
  184. #define STRIP_CRs(); {int c; while((c=our_fgetc(indoc))==RE) \
  185.               c = our_fgetc(indoc); \
  186.             our_ungetc(c,indoc); }
  187.  
  188. #define MAX(x,y) ((x) > (y) ? (x) : (y))
  189. #define FATAL_ERROR() { fprintf(stdout,error_msg);exit(99); }
  190. #define BLANK(string,length) memset(string,' ',length)
  191. #define EMPTY_CONTENT(ptr) (ptr->nodeid==EMPTY || ptr->contref_attr==TRUE)
  192. #define CLEAR_BUF();  { bufptr=0; clear_queue(); }
  193. #define IS_STARTTAG(token) ((token&HIGHBIT)!=HIGHBIT)
  194. #define IS_ENDTAG(token) (token&HIGHBIT)
  195. #define IS_ENDTAG_NOTEQ(token1,token2) ((token1&~HIGHBIT)!=token2)
  196. #define IS_ENDTAG_EQ(token1,token2) ((token1&~HIGHBIT)==token2)
  197. #define NULLTERM(string); {char *cptr; for (cptr=string+NAMELEN-1;cptr>=string&&*cptr==' ';cptr--); *(++cptr)='\0';}
  198. #define SGMLCHAR(c) ((c>31 && c<127) || (c>127 && c<255))
  199. #define SEPERATOR(c) (c==SPACE || c==RE || c==RS || c==SEPCHAR)
  200. #define NAMECHAR(c) (isalpha(c) || isdigit(c) || c=='.' || c=='-')
  201. #define NULLOI(ptr) ptr->occurind='#'
  202.  
  203. #define STARTMINI_MASK 0x1   /* start tag minimization was declared */
  204. #define ENDMINI_MASK 0x2     /* end tag minimization was declared */
  205. #define INCL_MASK 0x4        /* element was declared for inclusion */
  206. #define EXCL_MASK 0x8        /* element was declared for exclusion */
  207.  
  208. /* marked sections may be IGNORE, CDATA, RCDATA or INCLUDE */
  209. #define MS_INCLUDE (0)
  210. #define MS_RCDATA (MS_INCLUDE+1)
  211. #define MS_CDATA (MS_RCDATA+1)
  212. #define MS_IGNORE (MS_CDATA+1)
  213.  
  214. #define ELEMENT_CONTENT 0
  215. #define OTHER_CONTENT   1
  216.  
  217. #define OUR_EE -2 /* We have a problem of sign extension, so we */
  218.          /* are using -2 instead of 0xfe from dtd.h    */
  219.  
  220. #ifndef TRUE
  221. #define TRUE (1)
  222. #endif
  223. #ifndef FALSE
  224. #define FALSE (0)
  225. #endif
  226.